home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.9 KB  |  247 lines

  1. /* Copyright (C) 1991, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gp.h,v 1.5 2000/09/19 19:00:24 lpd Exp $ */
  20. /* Interface to platform-specific routines */
  21. /* Requires gsmemory.h */
  22.  
  23. #ifndef gp_INCLUDED
  24. #  define gp_INCLUDED
  25.  
  26. #include "gstypes.h"
  27. /*
  28.  * This file defines the interface to ***ALL*** platform-specific routines,
  29.  * with the exception of the thread/synchronization interface (gpsync.h)
  30.  * and getenv (gpgetenv.h).  The implementations are in gp_*.c files
  31.  * specific to each platform.  We try very hard to keep this list short!
  32.  */
  33. /*
  34.  * gp_getenv is declared in a separate file because a few places need it
  35.  * and don't want to include any of the other gs definitions.
  36.  */
  37. #include "gpgetenv.h"
  38. /*
  39.  * The prototype for gp_readline is in srdline.h, since it is shared with
  40.  * stream.h.
  41.  */
  42. #include "srdline.h"
  43.  
  44. /* ------ Initialization/termination ------ */
  45.  
  46. /*
  47.  * This routine is called early in the initialization.
  48.  * It should do as little as possible.  In particular, it should not
  49.  * do things like open display connections: that is the responsibility
  50.  * of the display device driver.
  51.  */
  52. void gp_init(P0());
  53.  
  54. /*
  55.  * This routine is called just before the program exits (normally or
  56.  * abnormally).  It too should do as little as possible.
  57.  */
  58. void gp_exit(P2(int exit_status, int code));
  59.  
  60. /*
  61.  * Exit the program.  Normally this just calls the `exit' library procedure,
  62.  * but it does something different on a few platforms.
  63.  */
  64. void gp_do_exit(P1(int exit_status));
  65.  
  66. /* ------ Miscellaneous ------ */
  67.  
  68. /*
  69.  * Get the string corresponding to an OS error number.
  70.  * If no string is available, return NULL.  The caller may assume
  71.  * the string is allocated statically and permanently.
  72.  */
  73. const char *gp_strerror(P1(int));
  74.  
  75. /* ------ Date and time ------ */
  76.  
  77. /*
  78.  * Read the current time (in seconds since an implementation-defined epoch)
  79.  * into ptm[0], and fraction (in nanoseconds) into ptm[1].
  80.  */
  81. void gp_get_realtime(P1(long ptm[2]));
  82.  
  83. /*
  84.  * Read the current user CPU time (in seconds) into ptm[0],
  85.  * and fraction (in nanoseconds) into ptm[1].
  86.  */
  87. void gp_get_usertime(P1(long ptm[2]));
  88.  
  89. /* ------ Reading lines from stdin ------ */
  90.  
  91. /*
  92.  * These routines are intended to provide an abstract interface to GNU
  93.  * readline or to other packages that offer enhanced line-reading
  94.  * capability.
  95.  */
  96.  
  97. /*
  98.  * Allocate a state structure for line reading.  This is called once at
  99.  * initialization.  *preadline_data is an opaque pointer that is passed
  100.  * back to gp_readline and gp_readline_finit.
  101.  */
  102. int gp_readline_init(P2(void **preadline_data, gs_memory_t *mem));
  103.  
  104. /*
  105.  * See srdline.h for the definition of sreadline_proc.
  106.  */
  107. int gp_readline(P9(stream *s_in, stream *s_out, void *readline_data,
  108.            gs_const_string *prompt, gs_string *buf,
  109.            gs_memory_t *bufmem, uint *pcount, bool *pin_eol,
  110.            bool (*is_stdin)(P1(const stream *))));
  111.  
  112. /*
  113.  * Free a readline state.
  114.  */
  115. void gp_readline_finit(P1(void *readline_data));
  116.  
  117. /* ------ Screen management ------ */
  118.  
  119. /*
  120.  * The following are only relevant for X Windows.
  121.  */
  122.  
  123. /* Get the environment variable that specifies the display to use. */
  124. const char *gp_getenv_display(P0());
  125.  
  126. /* ------ File naming and accessing ------ */
  127.  
  128. /*
  129.  * Define the maximum size of a file name returned by gp_open_scratch_file
  130.  * or gp_open_printer.  (This should really be passed as an additional
  131.  * parameter, but it would break too many clients to make this change now.)
  132.  * Note that this is the size of the buffer, not the maximum number of
  133.  * characters: the latter is one less, because of the terminating \0.
  134.  */
  135. #define gp_file_name_sizeof 128
  136.  
  137. /* Define the character used for separating file names in a list. */
  138. extern const char gp_file_name_list_separator;
  139.  
  140. /* Define the default scratch file name prefix. */
  141. extern const char gp_scratch_file_name_prefix[];
  142.  
  143. /* Define the name of the null output file. */
  144. extern const char gp_null_file_name[];
  145.  
  146. /* Define the name that designates the current directory. */
  147. extern const char gp_current_directory_name[];
  148.  
  149. /* Define the string to be concatenated with the file mode */
  150. /* for opening files without end-of-line conversion. */
  151. /* This is always either "" or "b". */
  152. extern const char gp_fmode_binary_suffix[];
  153.  
  154. /* Define the file modes for binary reading or writing. */
  155. /* (This is just a convenience: they are "r" or "w" + the suffix.) */
  156. extern const char gp_fmode_rb[];
  157. extern const char gp_fmode_wb[];
  158.  
  159. /* Create and open a scratch file with a given name prefix. */
  160. /* Write the actual file name at fname. */
  161. FILE *gp_open_scratch_file(P3(const char *prefix,
  162.                   char fname[gp_file_name_sizeof],
  163.                   const char *mode));
  164.  
  165. /* Open a file with the given name, as a stream of uninterpreted bytes. */
  166. FILE *gp_fopen(P2(const char *fname, const char *mode));
  167.  
  168. /* Force given file into binary mode (no eol translations, etc) */
  169. /* if 2nd param true, text mode if 2nd param false */
  170. int gp_setmode_binary(P2(FILE * pfile, bool mode));
  171.  
  172. /* Answer whether a file name contains a directory/device specification, */
  173. /* i.e. is absolute (not directory- or device-relative). */
  174. bool gp_file_name_is_absolute(P2(const char *fname, uint len));
  175.  
  176. /* Answer the string to be used for combining a directory/device prefix */
  177. /* with a base file name.  The file name is known to not be absolute. */
  178. const char *gp_file_name_concat_string(P4(const char *prefix, uint plen,
  179.                       const char *fname, uint len));
  180.  
  181. /* ------ Printer accessing ------ */
  182.  
  183. /*
  184.  * Open a connection to a printer.  A null file name means use the standard
  185.  * printer connected to the machine, if any.  Note that this procedure is
  186.  * called only if the original file name (normally the value of the
  187.  * OutputFile device parameter) was an ordinary file (not stdout, a pipe, or
  188.  * other %filedevice%file name): stdout is handled specially, and other
  189.  * values of filedevice are handled by calling the fopen procedure
  190.  * associated with that kind of "file".
  191.  *
  192.  * Note that if the file name is null (0-length) and a default printer is
  193.  * available, the file name may be replaced with the name of a scratch file
  194.  * for spooling.  If the file name is null and no default printer is
  195.  * available, this procedure returns 0.
  196.  */
  197. FILE *gp_open_printer(P2(char fname[gp_file_name_sizeof], int binary_mode));
  198.  
  199. /*
  200.  * Close the connection to the printer.  Note that this is only called
  201.  * if the original file name was an ordinary file (not stdout, a pipe,
  202.  * or other %filedevice%file name): stdout is handled specially, and other
  203.  * values of filedevice are handled by calling the fclose procedure
  204.  * associated with that kind of "file".
  205.  */
  206. void gp_close_printer(P2(FILE * pfile, const char *fname));
  207.  
  208. /* ------ File enumeration ------ */
  209.  
  210. #ifndef file_enum_DEFINED    /* also defined in iodev.h */
  211. #  define file_enum_DEFINED
  212. typedef struct file_enum_s file_enum;
  213. #endif
  214.  
  215. /*
  216.  * Begin an enumeration.  pat is a C string that may contain *s or ?s.
  217.  * The implementor should copy the string to a safe place.
  218.  * If the operating system doesn't support correct, arbitrarily placed
  219.  * *s and ?s, the implementation should modify the string so that it
  220.  * will return a conservative superset of the request, and then use
  221.  * the string_match procedure to select the desired subset.  E.g., if the
  222.  * OS doesn't implement ? (single-character wild card), any consecutive
  223.  * string of ?s should be interpreted as *.  Note that \ can appear in
  224.  * the pattern also, as a quoting character.
  225.  */
  226. file_enum *gp_enumerate_files_init(P3(const char *pat, uint patlen,
  227.                       gs_memory_t * memory));
  228.  
  229. /*
  230.  * Return the next file name in the enumeration.  The client passes in
  231.  * a scratch string and a max length.  If the name of the next file fits,
  232.  * the procedure returns the length.  If it doesn't fit, the procedure
  233.  * returns max length +1.  If there are no more files, the procedure
  234.  * returns -1.
  235.  */
  236. uint gp_enumerate_files_next(P3(file_enum * pfen, char *ptr, uint maxlen));
  237.  
  238. /*
  239.  * Clean up a file enumeration.  This is only called to abandon
  240.  * an enumeration partway through: ...next should do it if there are
  241.  * no more files to enumerate.  This should deallocate the file_enum
  242.  * structure and any subsidiary structures, strings, buffers, etc.
  243.  */
  244. void gp_enumerate_files_close(P1(file_enum * pfen));
  245.  
  246. #endif /* gp_INCLUDED */
  247.